<template>
  <div>
    <el-button type="success" icon="el-icon-edit" @click="createdStaff">添加员工</el-button>
    <createdStaff ref="staffChild" @update='update'></createdStaff>
    <el-table :data="list.data" stripe style="width: 100%;margin-top: 20px;" height="700">
      <el-table-column prop="realname" label="姓名" width="180">
      </el-table-column>
      <el-table-column prop="phone" label="电话">
      </el-table-column>
      <el-table-column prop="account" label="账户">
      </el-table-column>
      <el-table-column label="角色">
        <template slot-scope="scop">
          {{$roleId(scop.row.role) }}
        </template>
      </el-table-column>
      <el-table-column prop="departmentName" label="部门" width="300">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间">
      </el-table-column>
      <el-table-column prop="createTime" label="状态">
        <template slot-scope="scop">
          {{scop.row.status?'正常':'冻结'}}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scop">
          <el-button size="mini" @click="open(scop.row)" type="primary" icon="el-icon-edit">操作</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div style="display: flex;justify-content: flex-end;margin: 20px 0;">
      <basePagination :size="list.perPage" :page="list.currentPage" :total="list.total" @SizeChange='SizeChange'
        @CurrentChange='CurrentChange' />
    </div>

  </div>

  </div>
</template>

<script>
  import loader from '@/components/base/basePagination/controls.js';
  import createdStaff from '../../components/createdStaff.vue';

  export default {
    components: {
      createdStaff
    },
    mixins: [loader],
    data() {
      return {
        initial: {
          geturl: "/user/staff",
          params: {

          }
        },
        list: {},
        loading: true
      }
    },
    created() {
      this.jiazai()

    },
    methods: {
      jiazai() {
        this.getData(this.initial.params).then(res => {
          this.list = res;
          this.loading = false;
        }).catch(err => {

        })
      },

      createdStaff() {
        this.$refs.staffChild.dialogVisible = true;

      },
      update() {
          this.jiazai()
      },
      open(item) {
        this.$refs.staffChild.dialogVisible = true;
        this.$refs.staffChild.echo(item)
      }
    }
  }
</script>

<style>
</style>
